home *** CD-ROM | disk | FTP | other *** search
- unit TopWtchU;
-
- interface
-
- uses
- WinProcs, WinTypes, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
- StdCtrls, ExtCtrls;
-
- type
- TForm1 = class(TForm)
- RadioGroup1: TRadioGroup;
- Timer1: TTimer;
- procedure RadioGroup1Click(Sender: TObject);
- procedure Timer1Timer(Sender: TObject);
- end;
-
- var
- Form1: TForm1;
-
- implementation
-
- {$R *.DFM}
-
- function WatchWindow: HWnd;
- begin
- Result := FindWindow('TWatchWindow', 'Watch List');
- if Result = 0 then
- begin
- Form1.RadioGroup1.ItemIndex := -1;
- Abort;
- end;
- end;
-
- procedure WatchesOnTop(DoIt: Boolean);
- var
- Wnd: HWnd;
- const
- Flags: array[Boolean] of Longint = (HWnd_NoTopMost, HWnd_TopMost);
- begin
- Wnd := WatchWindow;
- { Check whether watch window is currently }
- { in appropriate state. If not, then change it }
- if (GetWindowLong(Wnd, gwl_ExStyle) and
- ws_Ex_TopMost <> 0) <> DoIt then
- SetWindowPos(Wnd, Flags[DoIt], 0, 0, 0, 0,
- swp_NoMove or swp_NoSize or swp_NoActivate);
- end;
-
- procedure TForm1.RadioGroup1Click(Sender: TObject);
- begin
- Timer1.Enabled := True
- end;
-
- procedure TForm1.Timer1Timer(Sender: TObject);
- begin
- { The timer is required because Delphi changes topmost }
- { windows to non-topmost windows when apps are }
- { launched and then back to topmost when they stop }
- WatchesOnTop(RadioGroup1.ItemIndex = 1);
- end;
-
- end.
-